﻿using System;
using System.Data;
using System.Windows.Forms;

namespace App.Common {
	public partial class ComboboxProvinceCityCounty : UserControl {
		public string strProvince, strCity, strCounty;
		private string[] arrProvince = new string[] { "", "北京市", "天津市", "河北省", "山西省", "内蒙古自治区", "辽宁省", "吉林省", "黑龙江省", "上海市", "江苏省", "浙江省", "安徽省", "福建省", "江西省", "山东省", "河南省", "湖北省", "湖南省", "广东省", "广西壮族自治区", "海南省", "重庆市", "四川省", "贵州省", "云南省", "西藏自治区", "陕西省", "甘肃省", "青海省", "宁夏回族自治区", "新疆维吾尔自治区", "台湾", "香港特别行政区", "澳门特别行政区" };
		//****************************************************************************************************
		public ComboboxProvinceCityCounty() {
			InitializeComponent();
		}
		//****************************************************************************************************
		private void CtrlCity_Load(object sender, EventArgs e) {
			setProvince("");
		}
		//****************************************************************************************************
		//省份
		private void setProvince(string str) {
			DataTable dt = new DataTable();

			DataColumn dcText = new DataColumn("text");
			DataColumn dcValue = new DataColumn("value");

			dt.Columns.Add(dcText);
			dt.Columns.Add(dcValue);

			foreach (string val in arrProvince) {
				DataRow dr = dt.NewRow();

				if (val == "") {
					dr["text"] = "--请选择省--";
				} else {
					dr["text"] = val;
				}

				dr["value"] = val;

				dt.Rows.Add(dr);
			}

			cmbProvince.DataSource = dt;
			cmbProvince.DisplayMember = "text";
			cmbProvince.ValueMember = "value";

			if (str == null) {
				cmbProvince.SelectedValue = "";
			} else {
				cmbProvince.SelectedValue = str.ToString();
			}
		}
		//****************************************************************************************************
	}
}
